function getBase64Image(img) {//base64转换
  var canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;
  var ctx = canvas.getContext("2d");
  ctx.drawImage(img, 0, 0, img.width, img.height);
  var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
  var dataURL = canvas.toDataURL("image/" + ext);
  return dataURL;
}

function compressImage(url) {//图片压缩
  // alert(1)
  plus.zip.compressImage({
      src: url,
      dst: "_doc/upload",
      quality: 50,
      overwrite: true
    },
    function (e) {
      return e.target
      alert(e.target)
    }, function (error) {
      // alert(error)
      throw error
    });
}

export default {
  getBase64Image,
  compressImage
}
